Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More ā†’
Socket
Sign inDemoInstall
Socket

colord

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colord

šŸ‘‘ A tiny yet powerful tool for high-performance color manipulations and conversions

  • 2.9.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.2M
decreased by-57.44%
Maintainers
1
Weekly downloads
Ā 
Created

What is colord?

The colord npm package is a tiny yet powerful tool for color conversions and manipulations. It provides functions for parsing colors, converting them between different color models, and manipulating their properties such as hue, saturation, lightness, and alpha channel.

What are colord's main functionalities?

Parsing and converting colors

This feature allows you to parse color strings and convert them to different color models. The example shows how to parse a hex color and convert it to an RGB object.

const { colord, extend } = require('colord');
const c = colord('#ff5733');
console.log(c.toRgb()); // { r: 255, g: 87, b: 51, a: 1 }

Manipulating color properties

This feature enables you to manipulate color properties such as alpha channel. The example demonstrates setting the alpha of an RGBA color and converting it to a string.

const { colord } = require('colord');
const color = colord('rgba(255, 87, 51, 1)');
console.log(color.alpha(0.5).toRgbString()); // 'rgba(255, 87, 51, 0.5)'

Mixing colors

This feature allows you to mix two colors together. The example mixes a color with white at a 50% ratio and outputs the hex value of the result.

const { colord } = require('colord');
const mix = colord('#ff5733').mix('#ffffff', 0.5).toHex();
console.log(mix); // '#ffaba9'

Generating readable colors

This feature helps in checking if a color is readable on another color, which is useful for accessibility. The example checks if the color '#ff5733' is readable on a white background.

const { colord, extend } = require('colord');
extend([require('colord/plugins/a11y')]);
const color = colord('#ff5733');
console.log(color.isReadable('#ffffff')); // true or false

Other packages similar to colord

Keywords

FAQs

Package last updated on 10 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc